www.gusucode.com > 黑白棋 V1.0 试用网络版源代码C++源码程序 > 黑白棋 V1.0 试用网络版源代码/BWChess/03D407_庞长才_PROJECT作业/BWChess钻石版/BWChess.cpp
// BWChess.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include "BWChess.h" #include "BWChessDlg.h" #include "HelperAPI.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CBWChessApp 本程序的核心应用程序对象 BEGIN_MESSAGE_MAP(CBWChessApp, CWinApp) //{{AFX_MSG_MAP(CBWChessApp) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CBWChessApp construction CBWChessApp::CBWChessApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CBWChessApp object CBWChessApp theApp;//程序从此处开始执行,先构造应用程序对象,再作相应的初始化 ///////////////////////////////////////////////////////////////////////////// // CBWChessApp initialization BOOL CBWChessApp::InitInstance() { HANDLE hMutex=::CreateMutex(NULL,FALSE,_T("bwchessmadebyshuker1228")); // “CreateMutex” 创建一个 互斥的mutex object对象 ,字符串为对象的名字 if(GetLastError()==ERROR_ALREADY_EXISTS) {//GetLastError() 检查是否已有该程序在运行(ERROR_ALREADY_EXISTS),若有则终止本程序! //MsgBox(IDS_ERROR_ALREADY_EXIST,IDS_TITLE_CHINESE); //return FALSE; } // AfxEnableControlContainer(); SetRegistryKey(_T("Spray Soft"));//在注册表里加入相应的信息 // this->SetDialogBkColor (RGB(255,255,255)); CBWChessDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); ::CloseHandle (hMutex); return FALSE; }